package com.wt.快速排序;

public class speediness2 {
   public void a(int arr[]){
        if(arr.length > 1 ){
            b(arr,0,arr.length-1);
        }
   }
   public void b(int arr[],int low,int high){
       if(low < high){
           int middle = c(arr,low,high);
           b(arr,low,middle-1);
           b(arr,middle+1,high);
       }

   }
   public int c(int arr[],int low,int high){
       int tem = arr[low];
       while (low < high) {
            while(low < high && arr[high] >= tem){
                    high--;
            }
            arr[low] = arr[high];
           while(low < high && arr[low] <= tem){
               low++;
           }
           arr[high] = arr[low];
       }
       arr[low] = tem;
       return low;
   }

    public static void main(String[] args) {
        int[] arr = {1, 7, 5, 6, 4, 2, 8, 9, 3, 10, 13, 12};
        speediness2 speediness2 = new speediness2();
        speediness2.a(arr);
        System.out.println("快速排序:");
        for(int i=0; i<arr.length; i++){
            System.out.print(arr[i]+"：");
        }
    }
}
